#ifndef _TaskQueue_HPP_
#define _TaskQueue_HPP_

#include "Mutex.hpp"
#include "Condition.hpp"

#include <vector>
#include <functional>

using std::vector;

namespace tp{
using ElemType = std::function<void()>;

class TaskQueue{
    friend class ThreadPool;
public:
    TaskQueue(int);
    ~TaskQueue();
    bool empty();
    bool full();
    void push(ElemType);
    ElemType pop();
private:
    void wakeup();

private:
    vector<ElemType> _que;
    int _que_size;
    Mutex _mutex;
    Condition _notEmpty;
    Condition _notFull;
    bool _flag; //退出标志
};

}

#endif

